<?php

session_start();

include_once "src/controller/blmanagement/UserAccountManagement.php";
include_once "src/model/User.php";
include_once "src/misc/ClientReponseGenerator.php";

try {

    $userId = $_POST["editUserId"];
    $name = $_POST["editUsername"];
    $type = $_POST["editUserType"];
    $pswd = $_POST["editPassword"];
    $email = $_POST["editEmail"];

    $user = new User();
    $user->setUserId($userId);
    $user->setName($name);
    $user->setType($type);
    $user->setPswd($pswd);
    $user->setEmail($email);
    sleep(1);
    if (UserAccountManagement::changeUserAccount($user)) {
        echo ClientReponseGenerator::simpleJsonResponse(1, "", "");
    } else {
        throw new Exception();
    }

} catch (Exception $e) {
    echo ClientReponseGenerator::simpleJsonResponse(0, "EditUserAccountException", "");
}

?>
